<?php

namespace App;

use App\Events\PostWasPublish;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $fillable = ['title', 'body', 'published'];

    protected $events = [
        'created' => PostWasPublish::class
    ];
    public function archive()
    {
        return $this->published = 0;
    }

    public function publish()
    {
        return $this->published = 1;
    }
}
